package com.song.tools.songtest.config;

import com.song.tools.songtest.component.CipherComponent;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

/**
 * 密文配置
 *
 * @author song tools
 * @since 2024-07-16
 */
@Slf4j
@Configuration
@EnableConfigurationProperties(CipherProperties.class)
public class CipherConfig {

    /**
     * 密文组件
     */
    @Bean
    @Primary
    public CipherComponent cipherComponent(@Autowired CipherProperties cipherProperties) {
        CipherComponent cipherComponent = new CipherComponent();
        CipherProperties.AES aes = cipherProperties.getAes();
        cipherComponent.setAesKey(aes.getKey());
        return cipherComponent;
    }
}
